package org.apache.database.enums;

import org.apache.database.dao.Condition;

import java.io.Serializable;

public enum  DeleteActionEnum  {
    BASE();
    private StringBuffer sql;

    DeleteActionEnum() {

    }
    public DeleteActionEnum init(){
        this.sql =new StringBuffer();
        this.sql.append("DELETE FROM ");
        this.sql.append(" ");
        return this;
    }
    public DeleteActionEnum withTableName(String tableName){
        this.sql.append(" "+tableName+" ");
        return this;
    }

    public String deleteById(Serializable id, Serializable idValue){
        this.sql.append(" WHERE ");
        this.sql.append(id);
        this.sql.append(" = ");
        this.sql.append(idValue instanceof String?"'"+idValue+"'":idValue);
        return sql.toString();
    }
    public String deleteByCondition(Condition condition){
        this.sql.append(condition.getSql());
        return sql.toString();
    }
}
